package cate.game.display.po;

import cate.common.game.GameCollection;
import cate.game.play.bg.HeroBg;
import cate.game.role.Role;
import cate.game.role.bag.hero.Hero;
import cate.game.util.GameKit;
import easy.java.dev.note.NoteField;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;

@Document(collection = GameCollection.NAME_HERO_DISPLAY)
public class HeroDisplay {

    public static final String AUTO_DELETE_FIELD = "expiredDate";

    @Id
    @NoteField("展示唯一ID")
    public String uid;

    @NoteField("英雄数据")
    public WatchHero hero;

    @NoteField("英雄背景")
    public HeroBg bg;

    @NoteField("过期时间")
    public Date expiredDate;


    public static HeroDisplay build(Role role, Hero hero) {
        HeroDisplay d = new HeroDisplay();
        d.uid = GameKit.uid();
        d.hero = new WatchHero(role,hero);
        d.bg = new HeroBg(role,hero);
        d.expiredDate = new Date(System.currentTimeMillis() + 24 * 3600 * 1000);
        return d;
    }
}
